package LeetCode.month01.day03;

import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;

public class No1456 {
    public static void main(String[] args) {
        String s = "eyqfwxejdgqsfrxppfes";
        int k = 3;
        System.out.println(maxVowels(s, k));
    }

    public static int maxVowels(String s, int k) {
        HashMap<Character,Integer> map = new HashMap<>();
        map.put('a',0);
        map.put('e',0);
        map.put('i',0);
        map.put('o',0);
        map.put('u',0);
        Queue<Character> queue = new LinkedList<>();
        int num = 0;
        int max = 0;
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            queue.offer(ch);
            if(map.containsKey(ch)){
                num++;
            }
            if(queue.size()>k&&map.containsKey(queue.poll())) num--;
            max=Math.max(num,max);
            //System.out.println(queue);
        }
        return max;
    }
}
